Fix an erroneous assertion in `cargo doc`
authorAlex Crichton <alex@alexcrichton.com>
Wed, 25 Mar 2015 19:51:23 +0000 (12:51 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 25 Mar 2015 19:51:23 +0000 (12:51 -0700)
src/cargo/ops/cargo_doc.rs
tests/test_cargo_doc.rs

index fdfe8e3f6845df912ec5856c6284af5ab70c788b..eb633f604ec704f36582851b0858a8ad35d9abdd 100644 (file)
@@ -24,7 +24,7 @@ pub fn doc(manifest_path: &Path,
     let mut lib_names = HashSet::new();
     let mut bin_names = HashSet::new();
     if options.compile_opts.spec.is_none() {
-        for target in package.targets() {
+        for target in package.targets().iter().filter(|t| t.documented()) {
             if target.is_lib() {
                 assert!(lib_names.insert(target.name()));
             } else {
index 27fb250e545c23b00a5b4c7985c88a40cb4c743b..8f0c23ce66abf859f1d03b9664b01bad8fa48f63 100644 (file)
@@ -245,3 +245,20 @@ test!(doc_dash_p {
 {compiling} a v0.0.1 (file://[..])
 ", compiling = COMPILING).as_slice()));
 });
+
+test!(doc_same_name {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("src/lib.rs", "")
+        .file("src/bin/main.rs", "fn main() {}")
+        .file("examples/main.rs", "fn main() {}")
+        .file("tests/main.rs", "fn main() {}");
+
+    assert_that(p.cargo_process("doc"),
+                execs().with_status(0));
+});